# Contributer: Fabian Affolter <fabian@affolter-engineering.ch>
# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Contributor: Jiri Kastner <cz172638@gmail.com>
# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=py3-cherrypy
_pkgreal=CherryPy
pkgver=18.8.0
pkgrel=3
pkgdesc="A pythonic, object-oriented web development framework"
url="https://cherrypy.dev/"
arch="noarch"
license="BSD-3-Clause"
depends="py3-cheroot py3-jaraco.collections py3-portend py3-zc.lockfile"
makedepends="py3-gpep517 py3-installer py3-setuptools py3-setuptools_scm py3-wheel"
checkdepends="py3-cheroot-tests py3-path py3-pytest py3-pytest-cov py3-requests-toolbelt py3-tz"
subpackages="$pkgname-tutorial $pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/C/CherryPy/CherryPy-$pkgver.tar.gz
	no-warn-fail.patch
	tests.patch
	test_timeout.patch
	gziptest.patch
	"
builddir="$srcdir/$_pkgreal-$pkgver"
replaces="py-cherrypy" # Backwards compatibility
provides="py-cherrypy=$pkgver-r$pkgrel" # Backwards compatibility
options="!check" # take forever

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest -W ignore::DeprecationWarning -W ignore:"unclosed ":ResourceWarning \
		--deselect=cherrypy/test/test_session.py::MemcachedSessionTest \
		--deselect=cherrypy/test/test_caching.py::CacheTest::test_antistampede \
		--deselect=cherrypy/test/test_static.py::StaticTest::test_file_stream
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl

	rm -rf "$pkgdir"/usr/lib/python3*/site-packages/cherrypy/test
}

tutorial() {
	pkgdesc="files for cherrypy tutorial"
	amove usr/lib/python3*/site-packages/cherrypy/tutorial
}

sha512sums="
abacc995c1757b8d0171d57eb59b6e5931c46019d8f0f43479e334bb4f58b61a27541d9d0997d665f81905bc3c89e42d40d8e5a6e3a5f9bf251bc9089ceb5249  CherryPy-18.8.0.tar.gz
fd3a58817a0d36d93deb46fea820c0422bf88159d18961b0d47d39124871b34fda2e2bec8416bfc6cc1a16af0160b5fc491bdf873b75d319716efa2dc19b47b8  no-warn-fail.patch
64d5e51822fca9045f76894a4e5322b80b2c7826eea21fc97e81bffe419a5f940481b807dad70eee53e4a31bc3598ed10252e7ae97c1d7dcb7ba4085ab3298d6  tests.patch
5d926f538f456e6b58de4c02da51bfa327c71a506bb5fc251303aa4838b311179324245401ec9c5af3043d7d31a3ee211d26344b12c82fc9ed36d666344b45da  test_timeout.patch
cc0384514a3cef41cbfcc441ba66a26feaf71cbd7ab092c8281782dfdfdccaa20cf5facf414e97cb88dd8e7c377067c8b6afdef4f71f22dee4c60db6a02c483b  gziptest.patch
"
